package com.cqut.forum.dao.imp;

import java.util.Date;
import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Component;

import com.cqut.forum.dao.UserLogDao;
import com.cqut.forum.entity.UserLog;

/**
 * 用户日志信息dao实现类
 * @author yangxun
 */
@Component
public class UserLogDaoImp extends BaseDaoImp implements UserLogDao{

	@SuppressWarnings("unchecked")
	public List<UserLog> getUserLog(Date date) {
		String hql = "select ul from UserLog where userLogTime = ?";
		Query query = super.getQuery(hql);
		query.setDate(0, date);
		
		List<UserLog> userLogs = query.list();
		return userLogs;
	}

	@SuppressWarnings("unchecked")
	public List<UserLog> getUserLog(int userId) {
		String hql = "select ul from UserLog where User.userId = ?";
		Query query = super.getQuery(hql);
		query.setInteger(0, userId);
		
		List<UserLog> userLogs = query.list();
		return userLogs;
	}
	
}
